﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'P_ListUserAlias')
	BEGIN
		DROP  Procedure  [esf_sso].P_ListUserAlias
	END

GO


CREATE Procedure [esf_sso].P_ListUserAlias
	@pAliasPart				VARCHAR (42) = NULL
	,@pListCount			INT = NULL
	,@pIsEnabled			BIT = NULL
AS

	SET NOCOUNT ON
	
	
	IF @pListCount IS NOT NULL
	BEGIN
		SET ROWCOUNT @pListCount
	END
	
	SELECT
		Alias
	FROM
		esf_sso.[User]
	WHERE
		(@pAliasPart IS NULL OR Alias LIKE @pAliasPart)
		AND (@pIsEnabled IS NULL OR IsEnabled = @pIsEnabled)
	ORDER BY
		Alias

GO